// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

Item {
    id: root

    Component.onCompleted: {
        root.esconder();
    }

    property variant modelo
    property int maxHeight: 50

    function mostrar() {
        root.state = "MOSTRA";
    }

    function esconder() {
        root.state = "ESCONDE";
    }

    Rectangle {
        id: rect
        anchors { fill: parent; margins: 4 }
        color: platformStyle.colorNormalMid
        border { width: 1; color: platformStyle.colorNormalLight }
        clip: true

        ListView {
            id: lst
            model: root.modelo
            anchors { fill: parent; margins: 1 }
            snapMode: ListView.SnapToItem

            delegate: Item {
                width: lst.width; height: colItem.height
                Column {
                    id: colItem
                    width: parent.width
                    spacing: 3
                    Row {
                        spacing: 5
                        width: parent.width
                        Image {
                            id: imgCheck
                            source: "qrc:///checkComplemento"
                        }
                        Text {
                            width: parent.width - imgCheck.width
                            text: modelData.complemento
                            color: platformStyle.colorNormalLight
                            font.pixelSize: 16
                            wrapMode: Text.WordWrap
                        }
                    }
                }
            }
        }
    }

    Behavior on height {
        SmoothedAnimation { property: "height"; duration: 500; }
    }

    states: [
        State {
            name: "MOSTRA"
            PropertyChanges { target: root; height: root.maxHeight }
        },
        State {
            name: "ESCONDE"
            PropertyChanges { target: root; height: 0; }
        }
    ]

    transitions: [
        Transition {
            from: "ESCONDE"; to: "MOSTRA"
        },
        Transition {
            from: "MOSTRA"; to: "ESCONDE"
        }
    ]
}
